#include <iostream>
#include <algorithm>
using namespace std;

struct homework
{
	int id, ddl, deduct;
};

int n;			// 作业数目
homework A[20]; // 作业数组
int day[20]{0}; // 记录某一天已经用于完成某作业

void do_homework()
{
	// 按照扣分降序排序（扣分相等时按截止日期升序排序）
	std::sort(A, A + n, [=](homework a, homework b) { return a.deduct == b.deduct ? (a.ddl < b.ddl) : (a.deduct > b.deduct); });
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		bool flag = false;
		for (int j = A[i].ddl; j > 0; j--)
		{
			if (day[j] == 0)
			{
				day[j] = A[i].id;
				flag = true;
				break;
			}
		}
		if (!flag)
			sum += A[i].deduct;
	}

	for (int i = 1; i <= n; i++)
		if (day[i] != 0)
			cout << day[i] << " ";

	cout << "\n"
		 << sum << endl;
}

int main()
{
	system("chcp 65001");

	cout << "请输入作业数量n：";
	cin >> n;
	cout << "请输入" << n << "个提交时间：\n";
	for (int i = 0; i < n; i++)
	{
		cin >> A[i].ddl;
		A[i].id = i + 1;
	}
	cout << "请输入" << n << "个逾期扣分：\n";
	for (int i = 0; i < n; i++)
		cin >> A[i].deduct;
	cout << "\n";

	do_homework();

	return 0;
}